/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Util;

/**
 *
 * @author Jack
 */
import java.sql.*;
import Database.ConnectToDatabase;
import java.util.Vector;

public class TypeReport {

    private int idtype;
    private String nametype;

    /**
     * @return the idtype
     */
    public int getIdtype() {
        return idtype;
    }

    /**
     * @param idtype the idtype to set
     */
    public void setIdtype(int idtype) {
        this.idtype = idtype;
    }

    /**
     * @return the nametype
     */
    public String getNametype() {
        return nametype;
    }

    /**
     * @param nametype the nametype to set
     */
    public void setNametype(String nametype) {
        this.nametype = nametype;
    }

    public Vector<TypeReport> ListIDD() {
        Vector<TypeReport> listd = new Vector<TypeReport>();
        try {
            Connection con = ConnectToDatabase.getConnection();
            String query = "select * from TypeReport";
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery(query);
            while (rs.next()) {
                TypeReport d = new TypeReport();
                d.setIdtype(rs.getInt("idtype"));
                d.setNametype(rs.getString("nameoftype"));
                listd.add(d);
            }
        } catch (Exception e) {
            listd = null;
        }
        return listd;
    }

    public static String ListType(int a) {
        String liste = "";
        try {
            Connection con = ConnectToDatabase.getConnection();
            String query = "select nameoftype from typereport,bugreport where bugreport.idtype=typereport.idtype and bugreport.idreport=" + a;
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery(query);
            while (rs.next()) {
                liste = rs.getString("nameoftype");
            }
        } catch (Exception ex) {
            liste = null;
        }
        return liste;
    }
}
